package com.lee.dutylower.activity;

import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;

import com.lee.dutylower.BaseActivity;
import com.lee.dutylower.R;
import com.lee.dutylower.task.CreateExcelTask;
import com.lee.dutylower.view.scheduling.OneDayScheduleFragment;

public class OneDayShowActivity extends BaseActivity {
    private OneDayScheduleFragment oneDayScheduleFragment;
    private int week;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_one_day_show);
        oneDayScheduleFragment = new OneDayScheduleFragment();
        Intent intent = getIntent();
        week = intent.getIntExtra("week",1);
        oneDayScheduleFragment.setDayofweek(week);
        if (!oneDayScheduleFragment.isAdded()){
            getFragmentManager().beginTransaction().replace(R.id.ll_replace,oneDayScheduleFragment, "oneday").commit();
        }else {
            getFragmentManager().beginTransaction().remove(oneDayScheduleFragment).commit();
            getFragmentManager().beginTransaction().replace(R.id.ll_replace,oneDayScheduleFragment, "oneday").commit();
        }
    }

    public void createExcel(View view) {
        CreateExcelTask createExcelTask = new CreateExcelTask(this,week);
        createExcelTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
    }
}
